<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>两两交换链表中的节点</title>
</head>
<body>
  <script>
    function fn(head) {
      if (head === null|| head.next === null) {
        return head;
      }
      const newHead = head.next;
      head.next = fn(newHead.next);
      newHead.next = head;
      return newHead;
    }
    console.log(fn([1,2,3,4]))
  </script>
</body>
</html>